//
//  WordListItemCell.m
//  Learn
//
//  Created by apple on 2024/4/4.
//  Copyright © 2024 迟建国. All rights reserved.
//

#import "WordListItemCell.h"
#import "UIButton+Extension.h"
@interface WordListItemCell ()
/* <#描述#> */
@property (nonatomic, strong) UILabel    * titleLabel;
@property (nonatomic, strong) UIButton    * extBtn;
@property (nonatomic, strong) UIView    * lineView;

@end

@implementation WordListItemCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self createUI];
    }
    return self;
}
- (void)createUI {
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.extBtn];
    [self.contentView addSubview:self.lineView];

}
- (UILabel *)titleLabel {
    if(!_titleLabel){
        _titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 14, 200, 22)];
        _titleLabel.textColor = UIColor.blackColor;
        _titleLabel.font = PingFangMediumFont(16);
        _titleLabel.textAlignment = NSTextAlignmentLeft;
    }
    return _titleLabel;
}
- (UIButton *)extBtn {
    if(!_extBtn){
        _extBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _extBtn.frame = CGRectMake(SCREEN_W-60, 10, 50, 30);
        _extBtn.centerY = self.titleLabel.centerY;
        
        [_extBtn setTitle:@"释义 " forState:UIControlStateNormal];
        [_extBtn setImage:[UIImage imageNamed:@"jiantou"] forState:(UIControlStateNormal)];
        [_extBtn setTitleColor:rgbHex(0x8e8e8e, 1) forState:UIControlStateNormal];
        _extBtn.titleLabel.font  = FONT_BODY_12;
        [_extBtn setupEdgeInsetsByDirection:(DFButtonImageDirectionRight)];
        _extBtn.userInteractionEnabled = NO;

    }
    return _extBtn;
}

- (UIView *)lineView {
    if(!_lineView){
        _lineView = [[UIView alloc]initWithFrame:CGRectMake(10, 50 , SCREEN_W, 0.5 )];
        
        _lineView.backgroundColor = rgbHex(0xe5e5e5, 1);
    }
    return _lineView;
}
- (void)updateItemCellModel:(id)itemModel {
//    @{@"key":key,@"words":dic[key]}
    if ([itemModel isKindOfClass:[NSDictionary class]]) {
        NSDictionary *dic = (NSDictionary *)itemModel;
        self.titleLabel.text = [NSString stringWithFormat:@"%@",dic[@"words_name"]];
    }
}
@end
